//Arnold Baghomian
//homework5
//baghomia.onid@oregonstate.edu
//CS362 assignment 3


#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


void testdiscardCard() {
    
typedef int bool;
#define true 1
#define false 0

 struct gameState GS;
 struct gameState* G = &GS;
 int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
           sea_hag, tribute, smithy};
  
//  int initializeGame(int numPlayers, int kingdomCards[10], int randomSeed,
//		   struct gameState *state) {

int player = 0;
initializeGame(2, k, 3141, G);
//3141 gives hand = copper copper estate copper copper

//test last card in hand
int handposition = 4;
int trashFlag = 0;
bool pass = true;
discardCard(handposition, player, G, trashFlag);
pass = pass && G->handCount[player] == 4;
pass = pass && G->hand[player][3] == copper;
pass = pass && G->hand[player][2] == estate;
pass = pass && G->hand[player][1] == copper;
pass = pass && G->hand[player][0] == copper;
pass = pass && G->playedCardCount == 1;
pass = pass && G->playedCards[0] == copper;
pass = pass && G->hand[player][4] == -1;

if (pass)
        printf("discardCard(): PASS discard last card\n");
    else
        printf("fullDeckCount(): FAIL discard last card\n");


// test card in middle
initializeGame(2, k, 3141, G);
handposition = 2;

trashFlag = 0;
pass = true;
discardCard(handposition, player, G, trashFlag);
pass = pass && G->handCount[player] == 4;
pass = pass && G->hand[player][3] == copper;
pass = pass && G->hand[player][2] == copper;
pass = pass && G->hand[player][1] == copper;
pass = pass && G->hand[player][0] == copper;
pass = pass && G->playedCardCount == 1;
pass = pass && G->playedCards[0] == estate;
pass = pass && G->hand[player][4] == -1;

if (pass)
        printf("discardCard(): PASS discard middle card\n");
    else
        printf("fullDeckCount(): FAIL discard middle card\n");


// test trash
initializeGame(2, k, 3141, G);
handposition = 2;

trashFlag = 1;
pass = true;
discardCard(handposition, player, G, trashFlag);
pass = pass && G->handCount[player] == 4;
pass = pass && G->hand[player][3] == copper;
pass = pass && G->hand[player][2] == copper;
pass = pass && G->hand[player][1] == copper;
pass = pass && G->hand[player][0] == copper;
pass = pass && G->playedCardCount == 0;
pass = pass && G->hand[player][4] == -1;

if (pass)
        printf("discardCard(): PASS discard middle card with trash\n");
    else
        printf("fullDeckCount(): FAIL discard middle card with trash\n");

// test last card
initializeGame(2, k, 3141, G);
player = 0;
trashFlag = 0;
pass = true;
G->handCount[player] = 1;
handposition = 0;
discardCard(handposition, player, G, trashFlag);
pass = pass && G->handCount[player] == 0;
pass = pass && G->playedCardCount == 1;
pass = pass && G->playedCards[0] == copper;
pass = pass && G->hand[player][0] == -1;

if (pass)
        printf("discardCard(): PASS discard last card\n");
    else
        printf("fullDeckCount(): FAIL discard last card\n");




}

int main(int argc, char *argv[])
{
    testdiscardCard();
    return 0;
}
